﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////


#pragma once
#include "GnufExplorerBlockManager.h"
#include "ComponentEditorGnufUI.h"

namespace gcmp
{
    class IDocument;
    class IModelView;
}

namespace gfam 
{
    class COMPONENT_EDITOR_GNUF_UI_EXPORT ConcreteModelViewBlock : public StaticExplorerBlock
    {
    public:
        ConcreteModelViewBlock(const std::wstring& name) : StaticExplorerBlock(name)
            , m_pDoc(nullptr)
            , m_IsProjectBlock(false)
        {}
        virtual ~ConcreteModelViewBlock() {}

        void setIsProjectBlock(bool isProjectBlock) { m_IsProjectBlock = isProjectBlock; }

    protected:
        virtual gnuf::TreeNode* initBlockImpl(gnuf::TreeBoard*) override;
        virtual void refresh(gcmp::IUiDocument*) override;
        virtual std::vector<std::wstring> getViewTypes() const = 0;
        virtual std::wstring getIcon() const = 0;
        virtual void setExtraData(gnuf::TreeNode*, gcmp::IModelView*) {}

        gcmp::IDocument* m_pDoc;
        bool m_IsProjectBlock; // 是否是项目Block
    };

    // 空视图，为了显示名称
    class COMPONENT_EDITOR_GNUF_UI_EXPORT EmptyModelViewBlock final : public ConcreteModelViewBlock
    {
    public:
        EmptyModelViewBlock(const std::wstring& name) : ConcreteModelViewBlock(name) {}
        virtual ~EmptyModelViewBlock() {}

    private:
        virtual std::vector<std::wstring> getViewTypes() const override { return{}; }
        virtual std::wstring getIcon() const override { return L""; }
        virtual gcmp::OwnerPtr<gnuf::TreeNodeSorter> getSorter() const override { return nullptr; }
    };

    //平面视图
    class COMPONENT_EDITOR_GNUF_UI_EXPORT PlanModelViewBlock final : public ConcreteModelViewBlock
    {
    public:
        PlanModelViewBlock(const std::wstring& name) : ConcreteModelViewBlock(name) {}
        virtual ~PlanModelViewBlock() {}

    private:
        virtual std::vector<std::wstring> getViewTypes() const override;
        virtual std::wstring getIcon() const override;
        virtual gcmp::OwnerPtr<gnuf::TreeNodeSorter> getSorter() const override;
    };

    //天花板视图
    class COMPONENT_EDITOR_GNUF_UI_EXPORT CeilingModelViewBlock final : public ConcreteModelViewBlock
    {
    public:
        CeilingModelViewBlock(const std::wstring& name) : ConcreteModelViewBlock(name) {}
        virtual ~CeilingModelViewBlock() {}

    private:
        virtual std::vector<std::wstring> getViewTypes() const override;
        virtual std::wstring getIcon() const override;
        virtual gcmp::OwnerPtr<gnuf::TreeNodeSorter> getSorter() const override;
    };

    //立面视图
    class COMPONENT_EDITOR_GNUF_UI_EXPORT ElevationModelViewBlock final : public ConcreteModelViewBlock
    {
    public:
        ElevationModelViewBlock(const std::wstring& name) : ConcreteModelViewBlock(name) {}
        virtual ~ElevationModelViewBlock() {}

    private:
        virtual std::vector<std::wstring> getViewTypes() const override;
        virtual std::wstring getIcon() const override;
        virtual gcmp::OwnerPtr<gnuf::TreeNodeSorter> getSorter() const override;
        virtual void setExtraData(gnuf::TreeNode*, gcmp::IModelView*) override;
    };

    //3D视图
    class COMPONENT_EDITOR_GNUF_UI_EXPORT View3DModelViewBlock final : public ConcreteModelViewBlock
    {
    public:
        View3DModelViewBlock(const std::wstring& name) : ConcreteModelViewBlock(name) {}
        virtual ~View3DModelViewBlock() {}

    private:
        virtual std::vector<std::wstring> getViewTypes() const override;
        virtual std::wstring getIcon() const override;
        virtual gcmp::OwnerPtr<gnuf::TreeNodeSorter> getSorter() const override;
    };
}